#pragma once

#include "Resource.h"

namespace ZeEngine
{
    class SDLTexture;
    class SpriteSheetAnimation;

    typedef std::map<std::string, SDL_Rect> SpriteSheetMap;
    typedef std::pair<std::string, SDL_Rect> SpriteSheetMapPair;

    typedef std::map<std::string, SpriteSheetAnimation*> SpriteSheetAnimationsMap;
    typedef std::pair<std::string, SpriteSheetAnimation*> SpriteSheetAnimationsMapPair;

    class SpriteSheet : public Resource
    {
        friend class ResourceManager;

    public:
        SpriteSheet(const std::string& strPath, const std::string& strName, const std::string& strGroup);
        virtual ~SpriteSheet();

        SDL_Rect GetSpriteBounds(const std::string& strName);
        SDLTexture* GetTexture() { return m_pTexture; }

        const SpriteSheetAnimation* GetAnimation(const std::string& strAnimationName) const;
        void AddAnimations(const std::string& strAnimationName, const std::string& strAnimationFile);

    private:
        virtual bool Load(ResourceLoader& loader);
        virtual void Unload(ResourceLoader& loader);

        bool LoadAnimations();

        void SetTexture(SDLTexture* pTexture);

    private:
        SpriteSheetMap m_sprites;
        SpriteSheetAnimationsMap m_animations;
        std::vector<std::string> m_animationsToLoad;
        SDLTexture* m_pTexture;
    };
}

